/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.flowumi.controladores.estudiante;

import com.flowumi.controladores.SessionFlowumiUtilBean;
import java.io.IOException;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.inject.Named;
import javax.enterprise.context.Dependent;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import org.apache.log4j.Logger;

/**
 *
 * @author ideacentre
 */
@ManagedBean
@RequestScoped
public class EstudianteEditorAlgoritmoBean implements Serializable {

    private static final Logger LOGGER =
            Logger.getLogger(EstudianteDetalleCursoBean.class);
    @ManagedProperty("#{sessionFlowumiUtil}")
    private SessionFlowumiUtilBean sessionBean;

    public void setSessionBean(SessionFlowumiUtilBean sessionBean) {
        this.sessionBean = sessionBean;
    }

    /**
     * Creates a new instance of EstudianteEditorAlgoritmoBean
     */
    public EstudianteEditorAlgoritmoBean() {
    }

    @PostConstruct
    public void init() {
        if (sessionBean.getUsuario().getIdRol() == null || sessionBean.getUsuario().getIdRol().getIdRol() != 3) {
            try {
                sessionBean.Desconectar();
                FacesContext.getCurrentInstance().getExternalContext().redirect("InicioSession.xhtml");
            } catch (IOException ex) {
                LOGGER.error(ex);
            }
        }
    }
}
